Skip to content

chore(lint): enable clippy::expect_used#98

Merged
tupe12334 merged 1 commit into
mainfrom
clippy/enable-expect_used
Jun 30, 2026
Merged

chore(lint): enable clippy::expect_used#98
tupe12334 merged 1 commit into
mainfrom
clippy/enable-expect_used

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Summary

Enables clippy::expect_used in [lints.clippy] and fixes the violations it surfaces.

  • issue/parse/{centy,gh,gitlab}.rs: strip_prefix(...).expect("caller checked ...")let Some(..) = .. else { unreachable!(..) } (these files are already excluded from the coverage gate; unreachable! avoids a panic! detour since clippy::panic is already denied here).
  • multi_workspace.rs::github_bare_path: now returns Result<PathBuf> and propagates a missing home directory via anyhow::Context instead of aborting (single call site, already inside a Result-returning caller).
  • commands/restore.rs::cmd_restore: same dirs::home_dir() fix via anyhow::Context.
  • issue/paths.rs::bare_clone_path_rooted and commands/restore.rs's path.parent() call: both are true invariants with no Result to propagate into (the former is a documented, intentional panic on the public bare_clone_path API; the latter would need a structurally-dead branch that breaks the repo's 100%-line-coverage pre-push gate). Both keep their .expect() behind a localized, reasoned #[allow(clippy::expect_used)].
  • Test-only .expect() calls (fixtures, where a descriptive panic message is the idiomatic way to fail a test fast) are exempted via #![cfg_attr(test, allow(clippy::expect_used))] in lib.rs and a matching file-level allow in tests/snapshot_tests.rs.

Closes #97

Test plan

  • cargo build
  • cargo clippy --all-targets --all-features -- -D warnings
  • cargo test (253 + 30 + 43 + 22 + 6 tests, all passing)
  • cargo fmt --check
  • Repo's own pre-push hook (build, clippy, line-limit, 100% line-coverage gate) — passes

This pull request was opened by the Clippy lint improvements → issue + PR (Rust repos) → Slack routine of moadim.

`.expect()` aborts the process with no chance to recover or attach
context, unlike the `anyhow::Result` propagation this crate already
uses throughout its command layer. Fix the seven production call
sites: three `strip_prefix(...).expect("caller checked ...")`
invariants in `issue/parse/*` (already excluded from the coverage
gate) become `unreachable!()` instead of a panic-macro detour, since
`clippy::panic` is already denied here; two `dirs::home_dir()`
lookups now propagate via `anyhow::Context` in functions that already
return `Result`; and the remaining two (a path-building helper with
no `Result` to propagate into, and a true invariant in `cmd_restore`
that would need a dead, coverage-breaking branch to express any other
way) keep their documented panic behind a localized, reasoned
`#[allow]`. Test-only `.expect()` calls (fixtures, where a
descriptive panic message is the idiomatic way to fail fast) are
exempted via a single `cfg(test)` crate attribute and an integration
test file allow.

Closes #97
@tupe12334

Copy link
Copy Markdown
Member Author

cc @tupe12334

@tupe12334 tupe12334 merged commit d365d02 into main Jun 30, 2026
1 check passed
@tupe12334 tupe12334 deleted the clippy/enable-expect_used branch June 30, 2026 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable clippy::expect_used lint

1 participant